this.showMsg('正在保存并生成标签，首次打印会较慢，请耐心等待...');

if (!this.getItem('frmLabel').isValid()) {
    this.showMsg('数据不完整，请查检。');
    return;
}

var me = this;
var vals = me.getItem('frmLabel').getValues();
if (parseFloat(vals.labelQty) > parseFloat(vals.deliveryQty)) {
    this.showMsg('最小包装数量不能超过送货数。',true);
    return;
}

var mainForm = me.getItem('frmMain');
var dtFrom = new Date();
var dtTo = new Date();
//dtFrom.setDate(dtFrom.getDate() - 1);
//dtTo.setDate(dtTo.getDate() + 1);
Ext.Msg.show({
    title: T.label.save,
    msg: T.msg.are_you_sure_to_save_data,
    icon: Ext.Msg.QUESTION,
    buttons: Ext.Msg.YESNO,
    fn: function(btnId) {
        if ('yes' == btnId) {
            button.setDisabled(true);

            YX.ZbusRpc.request({
                module: 'SmatSaveReceiveMaterialAndPrintService',
                showSuccess: false,
                params: vals,
                failure: function(rsp) {
                    me.showMsg('操作失败:' + rsp.rspDesc + "。",true);
                },
                success: function(rsp) {
                    me.showMsg('操作成功。');

                    me.getItem('frmLabel').getForm().setValues({
                        supCode: vals.supCode,
                        supName: vals.supName,
                        matCode: vals.matCode,
                        matDesc: vals.matDesc
                    });
                    me.loadReceiveMatLabelStore({
                        supCode: vals.supCode,
                        matCode: vals.matCode,
                        deliveryNo: vals.deliveryNo,
                        fromDate: dtFrom.startDay(),
                        toDate: dtTo.endDay()
                    });

                    if (!Ext.isEmpty(rsp.fileName)) {
                        Ext.create('Ext.window.Window', {
                            title: '标签打印',
                            height: mainForm.getHeight() - 50,
                            width: mainForm.getWidth() - 200,
                            layout: 'fit',
                            modal: true,
                            frame: false,
                            items: [{
                                html: '<iframe style="width:100%;height:100%" src="export?download=0&fileName=' + rsp.fileName + '"/>'
                            }]
                        }).show();
                    }
                },
                callback: function() {
                    button.setDisabled(false);
                }
            });
        }
    }
});